#!/usr/bin/python
# -*- coding: UTF-8 -*-
from UtilPackge import readExcel
from UtilPackge import Logger
import time

AttributeMate = ('品牌', '动漫地区', 'ACG作品名', '周边产品','出售状态','适用年龄','型号')

def allAttributeData(browser,filePath):

    sheetName = 'TypeAttribute'

    DataExcel = readExcel.readExceInfo(filePath,sheetName)

    #根据类目种类来确定进入那个方法
    sureTypeAttribute(DataExcel,browser,filePath)


def sureTypeAttribute(DataExcel,browser,filePath):

    for item in range(len(DataExcel)):
        #品牌
        if(AttributeMate[0]
                == DataExcel.get(item)[0]):
            writeBrand(browser,DataExcel.get(item)[1])

        #动漫地区
        if(AttributeMate[1]
                == DataExcel.get(item)[0]):
            region(browser,DataExcel.get(item)[1])

        #ACG作品名
        if(AttributeMate[2]
                == DataExcel.get(item)[0]):
            worksName(browser,DataExcel.get(item)[1])
            pass
        #周边产品
        if(AttributeMate[3]
                == DataExcel.get(item)[0]):
            peripheryProduct(browser,DataExcel.get(item)[1])
            pass

        #出售状态
        if(AttributeMate[4]
                == DataExcel.get(item)[0]):
            SellStatus(browser,DataExcel.get(item)[1])
            pass

        #适用年龄
        if(AttributeMate[5]
                == DataExcel.get(item)[0]):
            applyAge(browser,DataExcel.get(item)[1])
            pass

        #型号
        if(AttributeMate[6]
                == DataExcel.get(item)[0]):
            Model(browser,DataExcel.get(item)[1])
            pass
#写入品牌
def writeBrand(browser,itemData):
    browser.find_element_by_xpath(
        '//*[@id="struct-p-20000"]/div[2]/div[1]/span/div/div/input').send_keys(itemData)
    pass

#动漫地区
def region(browser,itemData):

    browser.find_element_by_xpath\
        ('//*[@id="struct-p-18821503"]/div[2]/div[1]/span').click()

    time.sleep(2)
    browser.find_element_by_xpath \
        ('/html/body/div[12]/div/div/div[1]/span/input').send_keys(itemData)

    time.sleep(2)
    browser.find_element_by_xpath \
        ('/html/body/div[12]/div/div/div[2]/div/div/div/div').click()

#ACG作品名
def worksName(browser,itemData):
    browser.find_element_by_xpath \
        ('//*[@id="struct-p-135924127"]/div[2]/div[1]/span/div/div/input').\
        send_keys(itemData)


#周边产品
def peripheryProduct(browser,itemData):
    browser.find_element_by_xpath \
        ('//*[@id="struct-p-3138517"]/div[2]/div[1]/span/div/div/input'). \
        send_keys(itemData)

#出售状态
def SellStatus(browser,itemData):
    browser.find_element_by_xpath \
        ('//*[@id="struct-p-6724495"]/div[2]/div[1]/span/span').click()

    time.sleep(4)
    browser.find_element_by_xpath \
        ('/html/body/div[14]/div/div/div[1]/span/input').send_keys(itemData)

    time.sleep(4)
    browser.find_element_by_xpath \
        ('/html/body/div[14]/div/div/div[2]/div/div/div/div').click()

#适用年龄
def applyAge(browser,itemData):
    browser.find_element_by_xpath \
        ('//*[@id="struct-p-20017"]/div[2]/div[1]/span/span').click()

    time.sleep(2)
    browser.find_element_by_xpath \
        ('/html/body/div[14]/div/div/div[1]/span/input').send_keys(itemData)

    time.sleep(2)
    browser.find_element_by_xpath \
        ('/html/body/div[14]/div/div/div[2]/div/div/div/div').click()

#型号
def Model(browser,itemData):
    browser.find_element_by_xpath \
        ('//*[@id="struct-p-20000~1"]/div[2]/div[1]/span/input').send_keys(itemData)
